<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title>我的首页</title>
  <script src="/javascript/javascript.js"></script>
  <script src="/javascript/jquery.js"></script>
  <script src="/javascript/jquery-3.1.1.js"></script>
  <script src="/javascript/popup.js"></script>
  <link rel="stylesheet" href="/stylesheets/toTop.css">
  <link rel="stylesheet" href="/stylesheets/style.css">
</head>
<body>
  <div class="top"></div>
<div class="navs">
<nav>
  <span><a class="homepage" href="/" title="广场">广场</a></span>
  <% if (user) { %>
  <span><a class="publish" href="/post">发布</a></span>
  <span><a class="save" href="/archive">存储库</a></span>
  <span><a class="mark" href="/tags">标签</a></span>
  <li class="userImg"><a href="/user"><img src=/images/<%= user.picUrl %> alt=""></a></li>
  <span><a class="out" href="/logout">退出</a></span>
  <%  } else { %>
  <span><a class="login" href="/login" title="登录">登录</a></span>
  <span><a class="register" href="/reg" title="注册">注册</a></span>
  <% } %>
  <!--搜索功能-->
  <span>
    <form action="/search" method="get" class="search">
      <input type="text" placeholder="SEARCH" name="keyword">
    </form>
  </span>
</nav>
<h1><%= title %></h1>
<article>
  <script>
    //提示弹出框
    $(function () {
      var success = '<%= success %>';
      var error = '<%= error %>';
      if (success) {
        $.popup(success);
        setTimeout(function () {
          $('.popup').fadeOut();
        }, 1000)
      }
      if (error) {
        $.popup(error);
        setTimeout(function () {
          $('.popup').fadeOut();
        }, 1000)
      }
    })

    //回到顶部
    $(function () {
      $(window).scroll(function () {
        var sc = $(window).scrollTop();
        if (sc > 0) {
          $('.top').css({"display": "block", "top": $(window).height() - 100});
        } else {
          $('.top').css('display', 'none')
        }

      })
      $('.top').click(function () {
        var sc = $(window).scrollTop();
        $('body,html').animate({scrollTop: 0}, 1000);
        $(this).animate({top: -200}, 1000)
      })
    })

  </script>